<template>
  <div id="app" class="night">
    <div class="bg"></div>
    <!-- 导航 -->
    <common-header></common-header>
    <!-- 中间内容 -->
    <keep-alive>
      <router-view class="night"/>
    </keep-alive>
    <!--底部-->
    <common-footer></common-footer>
    <div v-if="$route.name!=='Blog'">
<!--      <div class="my-cursor-pointer" style="bottom: 90px;right: 40px;box-shadow: none;position: fixed;width: 40px;height: 40px;" @click="changeMode">-->
<!--        <el-backtop :bottom="90" style="pointer-events:none">-->
<!--          <i title="白天/夜间模式切换" v-if="isSunny" class="el-icon-sunny"></i>-->
<!--          <i title="白天/夜间模式切换" v-else class="el-icon-moon"></i>-->
<!--        </el-backtop>-->
<!--      </div>-->
      <el-backtop></el-backtop>
    </div>
  </div>
</template>
<script>
  import $ from "jquery";

  var a_idx = 0
  $("body").click(function (e) {
    var a = ["❤富强❤", "❤民主❤", "❤文明❤", "❤和谐❤", "❤自由❤", "❤平等❤", "❤公正❤", "❤法治❤", "❤爱国❤", "❤敬业❤", "❤诚信❤", "❤友善❤"];
    var $i = $("<span/>").text(a[a_idx]);
    a_idx = (a_idx + 1) % a.length;
    var x = e.pageX, y = e.pageY;
    $i.attr('id','keyword')
    $i.attr('onselectstart','return false')
    $i.css({
      "z-index": 999,
      "top": y - 10,
      "left": x - 34,
      "font-size" : 18,
      "position": "absolute",
      "font-weight": "bold",
      "color": "#39A2F6",
      "cursor": "default",
    });
    $("body").append($i);
    $i.animate({
        "top": y - 100,
        "opacity": 0,
      },
      1500,
      function () {
        $i.remove();
      });
  });
  var selfLogin = false;
  var follow = $('#profile_block').find('#p_b_follow');
  var block = follow.length >= 1 ? follow[0] : "";
  var followText = (block != null && block != undefined) ? block.innerHTML : "";
  if(followText == "") selfLogin = true;

  var pageInfo = '\n---------------------\n著作权归作者所有。\n'
    + '商业转载请联系作者获得授权，非商业转载请注明出处。\n'
    + '作者：Chenyumeng\n源地址：' + document.location.href
    + '\n© 版权声明：本文为博主原创文章，转载请附上博文链接！';

  document.addEventListener('copy', function (ev) {
    var targetHTML = $.trim($(ev.target).html());
    if (targetHTML == "") return;
    if (!(targetHTML.startsWith('<table class="hljs-ln"') && targetHTML.endsWith('</table>')) || !selfLogin)  // isLogined
    {
      var selected = window.getSelection();
      var selectedText = selected.toString();
      let copyRightStr = (selectedText + pageInfo).replace(/\n/g, '\r\n'); // Solve the line breaks conversion issue

      ev.clipboardData.setData('text/plain', `${copyRightStr}`);
      ev.preventDefault();
    }
  });
  import CommonHeader from "./components/common/CommonHeader";
  import CommonFooter from "./components/common/CommonFooter";
  export default {
    name: "App",
    components: {CommonFooter, CommonHeader},
    data() {
      return {
        // isSunny: true,
      }
    },
    methods: {
    }
  }
</script>


<style lang="less">
  .bg {
    content: '';
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.8;
    position: fixed;
    background: center/cover no-repeat;
    background-image: url('https://chenyumengblog.oss-cn-hangzhou.aliyuncs.com/img/background.jpg');
    z-index: -1;
    pointer-events: none;
  }
  .my-span {
    position: absolute;
  }
  #app {
    -moz-user-select:none;/*火狐*/
    -webkit-user-select:none;/*webkit浏览器*/
    -ms-user-select:none;/*IE10*/
    -khtml-user-select:none;/*早期浏览器*/
    user-select:none;
  }
  #app a,text,p,span,h1,h2,h3,h4,h5,h6:hover {
    -moz-user-select:text;/*火狐*/
    -webkit-user-select:text;/*webkit浏览器*/
    -ms-user-select:text;/*IE10*/
    -khtml-user-select:text;/*早期浏览器*/
    user-select:text;
  }
</style>
